#include "ArrowBullet.h"

ArrowBullet::ArrowBullet()
{
    static SDL_Texture *tex_arrow = ResourcesManager::Instance().texturePool[ResID::Tex_BulletArrow];
    static const std::vector<int> idx_list = {0, 1};
    animation.SetLoop(true);
    animation.SetInterval(0.1);
    animation.SetFrameData(tex_arrow, 2, 1, idx_list);
    canRotated = true;
    size.x = 48, size.y = 48;
}

void ArrowBullet::OnCollide(Enemy *enemy)
{
    static ResourcesManager::SoundPool &sound_pool = ResourcesManager::Instance().soundPool;
    switch (rand() % 3) {
        case 0:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_ArrowHit_1], 0);
            break;
        case 1:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_ArrowHit_2], 0);
            break;
        case 2:
            Mix_PlayChannel(-1, sound_pool[ResID::Sound_ArrowHit_3], 0);
            break;
    }
    Bullet::OnCollide(enemy);
}